<template>
<div>

    <van-nav-bar title="选择假种" left-text="返回" left-arrow @click-left="onClickLeft" />

    <van-cell-group>
        <van-grid :column-num="3">
            <van-cell title="年休假" is-link to="" @click="check('LEAVE_ANNUAL','nxj')" />
            <van-cell title="调休假" is-link to="" @click="check('LEAVE_COMPENSATED','txj')" />
            <!-- 探亲假(父母) LEAVE_VISIT_PARENT  探亲假(配偶) LEAVE_VISIT_SPOUSE -->
            <van-cell title="探亲假" is-link to="" @click="select()" />
            <!-- <van-action-sheet  title="探亲假" v-model="show" :actions="actions" @select="onSelect" /> -->
            <van-cell title="哺乳假" is-link to="" @click="check('LEAVE_BREASTFEEDING','brj')" />
            <van-cell title="节育假" is-link to="" @click="check('LEAVE_CONTRACEPTION','jyj')" />
            <van-cell title="丧假" is-link to="" @click="check('LEAVE_FUNERAL','sangj')" />
            <van-cell title="婚假" is-link to="" @click="check('LEAVE_MARRIAGE','hj')" />
            <van-cell title="产假" is-link to="" @click="check('LEAVE_MATERNITY','cj')" />
            <van-cell title="陪产假" is-link to="" @click="check('LEAVE_PATERNITY','pcj')" />
            <van-cell title="护理假" is-link to="" @click="check('LEAVE_NURSING','hlj')" />
            <van-cell title="事假" is-link to="" @click="check('LEAVE_PERSONAL','sj')" />
            <van-cell title="病假" is-link to="" @click="check('LEAVE_SICK','bj')" />
        </van-grid>
    </van-cell-group>

</div>
</template>

<script>
import {
    ActionSheet
} from 'vant';

import {
    Dialog
} from 'vant';
import {
    Check
} from '@/api/fy';
export default {
    data() {
        return {
            show: false,
            actions: [{
                    name: '选项'
                },
                {
                    name: '选项'
                },
                {
                    name: '选项',
                    subname: '描述信息'
                },
            ],
        };
    },
    methods: {
        onSelect(item) {
            // 默认情况下点击选项时不会自动收起
            // 可以通过 close-on-click-action 属性开启自动收起
            this.show = false;
            Toast(item.name);
        },

        onClickLeft() {
            this.$router.go(-1); //返回上一层
        },
        check(type, url) {
            const obj = {
                recordType: type,
            }
            Check(obj).then(res => {
                const that = this;
                console.log(res);
                if (res.data.verCode == 1) {
                    that.$router.push({
                        path: url
                    });
                } else {
                    Dialog.alert({
                        message: res.data.msg,
                    }).then(() => {
                        // on close
                    });
                }
            })
        },
        select() {
            Dialog.confirm({
                    title: '温馨提示',
                    message: '请选择探亲类型',
                    confirmButtonText: "探望父母",
                    cancelButtonText: '探望配偶'
                })
                .then(() => {
                    this.check('LEAVE_VISIT_PARENT', 'tqjfm')
                })
                .catch(() => {
                    this.check('LEAVE_VISIT_SPOUSE', 'tqjpo')
                });
        },

    }
};
</script>

<style>

</style>
